<template>
  <el-main style="padding: 0px;">
    <el-form style="margin-top: 50px;" label-width="80px" :model="sysConfig">
      <el-form-item label="Hexo目录" label-width="120px">
        <el-input v-model="sysConfig.path"/>
      </el-form-item>
      <el-form-item label="七牛AK" label-width="120px">
        <el-input v-model="sysConfig.qiniuAccessKey"/>
      </el-form-item>
      <el-form-item label="七牛SK" label-width="120px">
        <el-input v-model="sysConfig.qiniuSecretKey"/>
      </el-form-item>
      <el-form-item label="七牛Bucket" label-width="120px">
        <el-input v-model="sysConfig.qiniuBucket"/>
      </el-form-item>
      <el-form-item label="七牛域名" label-width="120px">
        <el-input v-model="sysConfig.qiniuHost"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveConfig">保存配置</el-button>
      </el-form-item>
    </el-form>
  </el-main>
</template>

<script>
  import configManager from '@/service/ConfigManager'

  export default {
    data () {
      return {
        sysConfig: {
          base: '',
          qiniuAccessKey: '',
          qiniuSecretKey: '',
          qiniuBucket: '',
          qiniuHost: ''
        }
      }
    },
    created () {
      var me = this
      configManager.getSysConfig().then(sysConfig => {
        me.sysConfig = sysConfig
      })
    },
    methods: {
      saveConfig () {
        var me = this
        configManager.setSysConfig(this.sysConfig).then(() => {
          me.$notify({
            title: '成功',
            message: '保存成功',
            type: 'success'
          })
        })
      }
    }
  }
</script>
